home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.LayoutManager;
- import java.awt.Toolkit;
- import java.beans.PropertyChangeListener;
- import javax.swing.AbstractButton;
- import javax.swing.Action;
- import javax.swing.Icon;
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import javax.swing.JInternalFrame;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JSeparator;
- import javax.swing.UIManager;
- import javax.swing.event.InternalFrameEvent;
-
- public class BasicInternalFrameTitlePane extends JComponent {
- protected JMenuBar menuBar;
- protected JButton iconButton;
- protected JButton maxButton;
- protected JButton closeButton;
- protected JMenu windowMenu;
- protected JInternalFrame frame;
- protected Color selectedTitleColor;
- protected Color selectedTextColor;
- protected Color notSelectedTitleColor;
- protected Color notSelectedTextColor;
- protected Icon maxIcon;
- protected Icon minIcon;
- protected Icon iconIcon;
- protected Icon closeIcon;
- protected PropertyChangeListener propertyChangeListener;
- protected Action closeAction;
- protected Action maximizeAction;
- protected Action iconifyAction;
- protected Action restoreAction;
- protected Action moveAction;
- protected Action sizeAction;
- protected static final String CLOSE_CMD = "Close";
- protected static final String ICONIFY_CMD = "Minimize";
- protected static final String RESTORE_CMD = "Restore";
- protected static final String MAXIMIZE_CMD = "Maximize";
- protected static final String MOVE_CMD = "Move";
- protected static final String SIZE_CMD = "Size";
- // $FF: synthetic field
- static Class class$javax$swing$JInternalFrame;
-
- public BasicInternalFrameTitlePane(JInternalFrame var1) {
- this.frame = var1;
- this.installTitlePane();
- }
-
- public void addNotify() {
- super.addNotify();
- this.addSystemMenuItems(this.windowMenu);
- this.enableActions();
- }
-
- protected void addSubComponents() {
- ((Container)this).add(this.menuBar);
- ((Container)this).add(this.iconButton);
- ((Container)this).add(this.maxButton);
- ((Container)this).add(this.closeButton);
- }
-
- protected void addSystemMenuItems(JMenu var1) {
- JMenuItem var2 = var1.add(this.restoreAction);
- ((AbstractButton)var2).setMnemonic('R');
- var2 = var1.add(this.moveAction);
- ((AbstractButton)var2).setMnemonic('M');
- var2 = var1.add(this.sizeAction);
- ((AbstractButton)var2).setMnemonic('S');
- var2 = var1.add(this.iconifyAction);
- ((AbstractButton)var2).setMnemonic('n');
- var2 = var1.add(this.maximizeAction);
- ((AbstractButton)var2).setMnemonic('x');
- var1.add(new JSeparator());
- var2 = var1.add(this.closeAction);
- ((AbstractButton)var2).setMnemonic('C');
- }
-
- protected void assembleSystemMenu() {
- this.menuBar = this.createSystemMenuBar();
- this.windowMenu = this.createSystemMenu();
- this.menuBar.add(this.windowMenu);
- this.enableActions();
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- protected void createActions() {
- this.maximizeAction = new MaximizeAction(this);
- this.iconifyAction = new IconifyAction(this);
- this.closeAction = new CloseAction(this);
- this.restoreAction = new RestoreAction(this);
- this.moveAction = new MoveAction(this);
- this.sizeAction = new SizeAction(this);
- }
-
- protected void createButtons() {
- this.iconButton = new NoFocusButton(this);
- this.iconButton.addActionListener(this.iconifyAction);
- this.maxButton = new NoFocusButton(this);
- this.maxButton.addActionListener(this.maximizeAction);
- this.closeButton = new NoFocusButton(this);
- this.closeButton.addActionListener(this.closeAction);
- this.setButtonIcons();
- }
-
- protected LayoutManager createLayout() {
- return new TitlePaneLayout(this);
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return new PropertyChangeHandler(this);
- }
-
- protected JMenu createSystemMenu() {
- return new JMenu(" ");
- }
-
- protected JMenuBar createSystemMenuBar() {
- this.menuBar = new SystemMenuBar(this);
- this.menuBar.setBorderPainted(false);
- return this.menuBar;
- }
-
- protected void enableActions() {
- this.restoreAction.setEnabled(this.frame.isMaximum() || this.frame.isIcon());
- this.maximizeAction.setEnabled(this.frame.isMaximizable() && !this.frame.isMaximum());
- this.iconifyAction.setEnabled(this.frame.isIconifiable() && !this.frame.isIcon());
- this.closeAction.setEnabled(this.frame.isClosable());
- this.sizeAction.setEnabled(false);
- this.moveAction.setEnabled(false);
- }
-
- protected void installDefaults() {
- this.maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
- this.minIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
- this.iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
- this.closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
- this.selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
- this.selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
- this.notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
- this.notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
- }
-
- protected void installListeners() {
- this.propertyChangeListener = this.createPropertyChangeListener();
- this.frame.addPropertyChangeListener(this.propertyChangeListener);
- }
-
- protected void installTitlePane() {
- this.installDefaults();
- this.installListeners();
- this.createActions();
- this.enableActions();
- ((Container)this).setLayout(this.createLayout());
- this.assembleSystemMenu();
- this.createButtons();
- this.addSubComponents();
- }
-
- public void paintComponent(Graphics var1) {
- boolean var2 = this.frame.isSelected();
- if (var2) {
- var1.setColor(this.selectedTitleColor);
- } else {
- var1.setColor(this.notSelectedTitleColor);
- }
-
- var1.fillRect(0, 0, ((JComponent)this).getWidth(), ((JComponent)this).getHeight());
- if (this.frame.getTitle() != null) {
- Font var3 = var1.getFont();
- var1.setFont(UIManager.getFont("InternalFrame.titleFont"));
- if (var2) {
- var1.setColor(this.selectedTextColor);
- } else {
- var1.setColor(this.notSelectedTextColor);
- }
-
- FontMetrics var4 = var1.getFontMetrics();
- int var5 = var4.getHeight() - var4.getLeading();
- int var6 = (18 - var5) / 2 + var4.getAscent() + var4.getLeading();
- var1.drawString(this.frame.getTitle(), this.menuBar.getX() + this.menuBar.getWidth() + 2, var6);
- var1.setFont(var3);
- }
-
- }
-
- protected void postClosingEvent(JInternalFrame var1) {
- InternalFrameEvent var2 = new InternalFrameEvent(var1, 25550);
- if ((class$javax$swing$JInternalFrame != null ? class$javax$swing$JInternalFrame : (class$javax$swing$JInternalFrame = class$("javax.swing.JInternalFrame"))).getClassLoader() == null) {
- try {
- Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(var2);
- return;
- } catch (SecurityException var3) {
- }
- }
-
- ((Component)var1).dispatchEvent(var2);
- }
-
- public void removeNotify() {
- super.removeNotify();
- if (this.windowMenu != null) {
- this.windowMenu.removeAll();
- }
-
- this.uninstallDefaults();
- }
-
- protected void setButtonIcons() {
- if (this.frame.isIcon()) {
- this.iconButton.setIcon(this.minIcon);
- this.maxButton.setIcon(this.maxIcon);
- } else if (this.frame.isMaximum()) {
- this.iconButton.setIcon(this.iconIcon);
- this.maxButton.setIcon(this.minIcon);
- } else {
- this.iconButton.setIcon(this.iconIcon);
- this.maxButton.setIcon(this.maxIcon);
- }
-
- this.closeButton.setIcon(this.closeIcon);
- }
-
- protected void showSystemMenu() {
- this.windowMenu.doClick();
- }
-
- protected void uninstallDefaults() {
- }
- }
-